Repository navigation
feat(codegen-kotlin): add KotlinWriter and move 14 small generators onto it - #658
Merged
Merged
Conversation
…ors on it Adds the Kotlin dialect of the ADR-0063 code writer (KotlinWriter in codegen-kotlin, on the shared codegen-base core), ten kotlin cases in fixtures/writer-conformance/ beside the core ones, and a layout ratchet (KotlinLayoutRatchetTest, using the Kotlin compiler's lexer) with a shrink-only allowlist seeded with every file still typing its layout. Converts the fourteen small generators onto the writer: names, filter allowlist, decimal and duration wire, validation issues, unknown body keys, validator, extractor, output parser, output prompt, render helper, stored proc, report export and requirement tests. Their output changes in layout only (sorted imports, a list that fits on one line, trailing commas, one-line KDoc, no blank line at a block's start, a blank line after a file header); the snapshot goldens move with it. The public methods an owned copy ejected at an earlier version calls are kept. The writer classes join the Kotlin eject engine surface; spec/code-writer.md, the writer corpus README, docs/CONFORMANCE.md and CHANGELOG.md describe the Kotlin dialect, and gate_conf_kotlin runs the writer and ratchet tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
KotlinWriter(server/java/codegen-kotlin/.../kotlin/writer/KotlinWriter.kt), a Kotlin dialect of the sharedcodegen-baseCodeWriter(ADR-0063, contract inspec/code-writer.md). It collects and sorts imports, handlesasaliases and keyword segments, escapes$in strings, writes KDoc, and offersblock,reopenandindentedscoped forms. The sharedfixtures/writer-conformance/corpus gains tenkotlincases, andKotlinLayoutRatchetTestkeeps a shrink-only allowlist of emitters not yet converted.KotlinWriter,CodeWriter,GroupandWriterOptionsoneject.engineSurface.kotlin.engine, updatesdocs/CONFORMANCE.md,spec/code-writer.mdand the 1.3.0 CHANGELOG, and adds the writer and ratchet tests to the Kotlin conformance lane (gate_conf_kotlin) inscripts/ci-local.sh. The pipeline's document step also added Kotlin writer pointers todocs/ports/kotlin.mdanddocs/features/own-your-codegen.md.The golden diff is layout
Every changed snapshot under
server/java/codegen-kotlin/src/test/resources/snapshots/(24 files) changes layout only: imports sorted into one group, a list that fits written on one line, a trailing comma on a broken list, one-line KDoc for a single entry, no blank line at a block's start, and a blank line after a file header. No identifier, type, expression or literal value changes. The one exact-string test updated (KotlinReportRestSurfaceTest) moves for the same reasons.Test exception (approved)
The gate's Test step returned
inconclusivebecause it drove no livemvn metaobjects:generaterun, and that exception was approved. The check it asked for is covered by the full Kotlin suite, which passed 683 of 683 locally on this head. That suite includes the snapshot goldens and the codegen-kotlin compile gate, which generates fromfixtures/persistence-conformance/canonical/meta.fitness.jsonand compiles the output withKotlinCompilation, and CI reruns it. Also green locally: the maven-plugin eject contract tests, the TypeScript and Python writer-case runners, andscripts/ci-local.sh --only gates.no-mistakes: 1 run.
Validation
Risk Assessment
✅ Low: The change adds a new writer and moves fourteen emitters onto it. Every golden diff is layout only: import order, list fitting, trailing commas, one-line KDoc, and blank lines at block starts and after headers. The fixed-content emitters are byte-identical apart from import order and the final newline, and the public engine surface that ejected copies call is kept.
Testing
Baseline
scripts/ci-local.sh --affected --strict-toolchainspassed. This turn ran the focused Kotlin writer conformance and layout ratchet tests in-process, and both passed (42 and 20 tests). These are unit-level runs, not live product runs, so no scenario is marked live. The user-facing behavior (regenerated Kotlin is layout-only and still compiles) was not driven end-to-end, so the verdict is inconclusive.mvn -ampackage plusmetaobjects:generatein a scrat…Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
mvn metaobjects:generaterun on fixtures/persistence-conformance to confirm.mvn -ampackage plusmetaobjects:generatein a scrat…scripts/ci-local.sh --affected --strict-toolchainsmvn -o -q -pl codegen-kotlin -am -Dtest='KotlinWriterConformanceTest,KotlinLayoutRatchetTest,LayoutRatchetTest' -Dsurefire.failIfNoSpecifiedTests=false testin server/java: exit 0; surefire KotlinWriterConformanceTest 42 run, 0 fail; KotlinLayoutRatchetTest 20 run, 0 fail (reports fresh, 04:21)Baseline from configured commandscripts/ci-local.sh --affected --strict-toolchainsalready passed at target commit; not re-run, no source changed in this turn✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.